﻿using System;
using System.Threading.Tasks;

using MassTransit;
using MQNamespace;
namespace Athena
{
    public abstract class RequestModelPublish : IBaseRequestModel, IBasePublish
    {
        public RequestModelPublish()
        {
            CorrelationId = Guid.NewGuid();
            TimeStamp = DateTime.Now;
        }
        public RequestModelPublish(Guid? correlationId)
        {
            CorrelationId = correlationId;
            TimeStamp = DateTime.Now;
        }

        public Guid? CorrelationId
        {
            get;
        }

        public DateTime TimeStamp
        {
            get;
        }

        private string _publishUri;

        public string PublishUri
        {
            get
            {
                return _publishUri;
            }
        }

        protected ISendEndpoint BusControl
        {
            get;
            set;
        }

        public virtual void Initialization(ISendEndpoint busControl)
        {
            BusControl = busControl;
        }

        public async Task Publish()
        {
            //await BusControl.Publish(this, context => { context.DestinationAddress = new Uri(_publishUri); });
        }

        public virtual async Task Publish(string uri)
        {
            //await BusControl.Publish(this, context => { context.DestinationAddress = new Uri(uri); });
        }
    }
}
